package com.gitee.itembucket.core.bucket

import org.bukkit.inventory.ItemStack
import taboolib.module.nms.getName

class ViolateItem(val string: String) {

    private val split = string.split("=")
    val type = Type.valueOf(split[0].uppercase())
    val value = split[1]


    enum class Type {
        NAME {
            override fun check(itemStack: ItemStack, value: String): Boolean {
                return itemStack.getName().contains(value)
            }
        },
        ID {
            override fun check(itemStack: ItemStack, value: String): Boolean {
                return itemStack.type.name.uppercase().contains(value.uppercase())
            }
        },
        LORE {
            override fun check(itemStack: ItemStack, value: String): Boolean {
                return itemStack.itemMeta?.lore?.any { value in it } ?: false
            }
        };

        abstract fun check(itemStack: ItemStack, value: String): Boolean

    }

}